<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8"/>
    <title>Vue示例</title>
</head>

<body>
<div id="app">
    {{message}}
    <component-a></component-a>
</div>
<script charset="utf-8" src="../js/vue.min.js" type="text/javascript"></script>
<script type="text/javascript">
    Vue.component('component-a', {
        template: '<button @click="handleEvent">通过父链直接修改数据</button>',
        methods: {
            handleEvent: function () {
                //访问到父链后,可以做任何操作,比如直接修改数据
                this.$parent.message = '来自组件component-a的内容';
            }
        }
    });
    var app = new Vue({
        el: '#app',
        data: {
            message: ''
        }
    })
</script>
</body>

</html>
